package com.example.demo.demos.web.Services.impl;

import com.example.demo.demos.web.Services.VulnService;
import com.example.demo.demos.web.mapper.VulnMapper;
import com.example.demo.demos.web.po.Vuln;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @BelongsProject: demo1
 * @BelongsPackage: com.example.demo.demos.web.Services.impl
 * @Author: Hu1er
 * @CreateTime: 2023-06-28  16:50
 * @Description: TODO
 * @Version: 1.0
 */

@Service
public class VulnServiceImpl implements VulnService {
    @Autowired
    private VulnMapper vulnMapper;

    @Override
    public int add(Vuln vuln) {
        int result = vulnMapper.insert(vuln);
        if (result > 0){
            return result;
        }else {
            return 0;
        }
    }

    @Override
    public int del(int id) {
        int result = vulnMapper.deleteByID(id);
        if (result > 0){
            return result;
        }else {
            return 0;
        }

    }

    @Override
    public int update(Vuln vuln) {
        int result = vulnMapper.updateByID(vuln);
        if (result > 0){
            return result;
        }else {
            return 0;
        }

    }

    @Override
    public List<Vuln> selectByNameFuzz(String vulnName) {
        List<Vuln> vulns = vulnMapper.selectByNameFuzz(vulnName);
        if (!vulns.isEmpty()){
            return vulns;
        }else {
            return null;
        }

    }
}
